package kr.memo.controller;

import kr.memo.dao.MemoDao;
import kr.memo.domain.MemoCommand;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class MemoDeleteController {

	
	@Autowired
	private MemoDao memoDao;
	
	
	@ModelAttribute("command")
	public MemoCommand formBacking(){
		return new MemoCommand();
	}
	@RequestMapping(value="deleteMemo.do", method=RequestMethod.GET)
	public String form(@RequestParam("memo_no")int memo_no,
					   @RequestParam("p_num") int p_num){
					   
		
		memoDao.deleteMemo(memo_no);
		return "redirect:/memoList.do?p_num="+p_num;
		
	}
}
